<?php

/**
 * @version		$Id: hello.php 15 2009-11-02 18:37:15Z chdemko $
 * @package		Joomla16.Tutorials
 * @subpackage	Components
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @author		Christophe Demko
 * @link		http://joomlacode.org/gf/project/helloworld_1_6/
 * @license		License GNU General Public License version 2 or later
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelitem library
jimport('joomla.application.component.modelitem');

/**
 * HelloWorld Model
 */
class bgModelbg extends JModel
{
	var $_total = null;
    var $_pagination = null;
    
    public function __construct(){
    	parent::__construct();
 
        $mainframe = JFactory::getApplication();
 
        // Get pagination request variables
        $limit = $mainframe->getUserStateFromRequest('com_activity.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
        $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
 
        // In case limit has been changed, adjust it
        $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
 
        $this->setState('limit', $limit);
        $this->setState('limitstart', $limitstart);
    }
    /**
     *save data in database 
    **/
    function save($data = null,$addNew = false){
       if($addNew){
           $qr = "INSERT INTO actt (ACTT_CODE,ACTT_NAME,ACTT_RECOMMENDED_DEGREE,ACTT_OCBA_CODE,ACTT_PERIOD_START,ACTT_PERIOD_FINISH,ACTT_VENUE,ACTT_TOCHUC,ACTT_TAITRO,ACTT_COOPERATION,ACTT_CONTACT,ACTT_EFFECT,ACTT_TARGET,ACTT_SEX,ACTT_NUMBER_OF_PARTICIPANTS,ACTT_ENTRY_FEE,ACTT_TOTAL_PROJECT_COST,ACTT_BUSINESS,ACTT_REMARKS,ACTT_MFAC_CODE_LIST,ACTT_MOBJ_CODE_LIST,ACTT_MCON_CODE_LIST,ACTT_IMAGE_1,ACTT_IMAGE_2,ACTT_IMAGE_3,ACTT_IMAGE_4,ACTT_IMAGE_5,ACTT_DECR_IMG_1,ACTT_DECR_IMG_2,ACTT_DECR_IMG_3,ACTT_DECR_IMG_4,ACTT_DECR_IMG_5,ACTT_ATTACHMENT_1,ACTT_ATTACHMENT_2,ACTT_ATTACHMENT_3,ACTT_ATTACHMENT_4,ACTT_ATTACHMENT_5,ACTT_ATTACHMENT_6,ACTT_DECR_ATT_1,ACTT_DECR_ATT_2,ACTT_DECR_ATT_3,ACTT_DECR_ATT_4,ACTT_DECR_ATT_5,ACTT_DECR_ATT_6,ACTT_DATE,ACTT_WEBF,ACTT_FLAG,ACTT_USER_CREATE,ACTT_RECR,ACTT_PERSON,ACTT_TEL)
                             VALUES ($data[ACTT_CODE],'$data[ACTT_NAME]',$data[ACTT_RECOMMENDED_DEGREE],'$data[ACTT_OCBA_CODE]','$data[ACTT_PERIOD_START]','$data[ACTT_PERIOD_FINISH]','$data[ACTT_VENUE]','$data[ACTT_TOCHUC]','$data[ACTT_TAITRO]','$data[ACTT_COOPERATION]','$data[ACTT_CONTACT]','$data[ACTT_EFFECT]','$data[ACTT_TARGET]',$data[ACTT_SEX],'$data[ACTT_NUMBER_OF_PARTICIPANTS]','$data[ACTT_ENTRY_FEE]','$data[ACTT_TOTAL_PROJECT_COST]','$data[ACTT_BUSINESS]','$data[ACTT_REMARKS]','$data[ACTT_MFAC_CODE_LIST]','$data[ACTT_MOBJ_CODE_LIST]','$data[ACTT_MCON_CODE_LIST]','$data[ACTT_IMAGE_1]','$data[ACTT_IMAGE_2]','$data[ACTT_IMAGE_3]','$data[ACTT_IMAGE_4]','$data[ACTT_IMAGE_5]','$data[ACTT_DECR_IMG_1]','$data[ACTT_DECR_IMG_2]','$data[ACTT_DECR_IMG_3]','$data[ACTT_DECR_IMG_4]','$data[ACTT_DECR_IMG_5]','$data[ACTT_ATTACHMENT_1]','$data[ACTT_ATTACHMENT_2]','$data[ACTT_ATTACHMENT_3]','$data[ACTT_ATTACHMENT_4]','$data[ACTT_ATTACHMENT_5]','$data[ACTT_ATTACHMENT_6]','$data[ACTT_DECR_ATT_1]','$data[ACTT_DECR_ATT_2]','$data[ACTT_DECR_ATT_3]','$data[ACTT_DECR_ATT_4]','$data[ACTT_DECR_ATT_5]','$data[ACTT_DECR_ATT_6]','$data[ACTT_DATE]',$data[ACTT_WEBF],$data[ACTT_FLAG],$data[ACTT_USER_CREATE],$data[ACTT_RECR],'$data[ACTT_PERSON]','$data[ACTT_TEL]')"; 
           
                     
       }else{
          $qr = "UPDATE actt  SET  ACTT_NAME = '$data[ACTT_NAME]',ACTT_RECOMMENDED_DEGREE = $data[ACTT_RECOMMENDED_DEGREE],ACTT_OCBA_CODE = '$data[ACTT_OCBA_CODE]'
                                    ,ACTT_PERIOD_START = '$data[ACTT_PERIOD_START]',ACTT_PERIOD_FINISH = '$data[ACTT_PERIOD_FINISH]',ACTT_VENUE = '$data[ACTT_VENUE]'
                                    ,ACTT_TOCHUC = '$data[ACTT_TOCHUC]',ACTT_TAITRO = '$data[ACTT_TAITRO]',ACTT_COOPERATION = '$data[ACTT_COOPERATION]',ACTT_CONTACT = '$data[ACTT_CONTACT]'
                                    ,ACTT_EFFECT = '$data[ACTT_EFFECT]',ACTT_TARGET = '$data[ACTT_TARGET]',ACTT_SEX = $data[ACTT_SEX],ACTT_NUMBER_OF_PARTICIPANTS = '$data[ACTT_NUMBER_OF_PARTICIPANTS]'
                                    ,ACTT_ENTRY_FEE = '$data[ACTT_ENTRY_FEE]',ACTT_TOTAL_PROJECT_COST = '$data[ACTT_TOTAL_PROJECT_COST]',ACTT_BUSINESS = '$data[ACTT_BUSINESS]',ACTT_REMARKS = '$data[ACTT_REMARKS]'
                                    ,ACTT_MFAC_CODE_LIST = '$data[ACTT_MFAC_CODE_LIST]',ACTT_MOBJ_CODE_LIST = '$data[ACTT_MOBJ_CODE_LIST]',ACTT_MCON_CODE_LIST = '$data[ACTT_MCON_CODE_LIST]'
                                    ,ACTT_IMAGE_1 = '$data[ACTT_IMAGE_1]',ACTT_IMAGE_2 = '$data[ACTT_IMAGE_2]',ACTT_IMAGE_3 = '$data[ACTT_IMAGE_3]',ACTT_IMAGE_4 = '$data[ACTT_IMAGE_4]',ACTT_IMAGE_5 = '$data[ACTT_IMAGE_5]'
                                    ,ACTT_DECR_IMG_1 = '$data[ACTT_DECR_IMG_1]',ACTT_DECR_IMG_2 = '$data[ACTT_DECR_IMG_2]',ACTT_DECR_IMG_3 = '$data[ACTT_DECR_IMG_3]',ACTT_DECR_IMG_4 = '$data[ACTT_DECR_IMG_4]',ACTT_DECR_IMG_5 = '$data[ACTT_DECR_IMG_5]'
                                    ,ACTT_ATTACHMENT_1 = '$data[ACTT_ATTACHMENT_1]',ACTT_ATTACHMENT_2 = '$data[ACTT_ATTACHMENT_2]',ACTT_ATTACHMENT_3 = '$data[ACTT_ATTACHMENT_3]',ACTT_ATTACHMENT_4 = '$data[ACTT_ATTACHMENT_4]',ACTT_ATTACHMENT_5 = '$data[ACTT_ATTACHMENT_5]',ACTT_ATTACHMENT_6 = '$data[ACTT_ATTACHMENT_6]'
                                    ,ACTT_DECR_ATT_1 = '$data[ACTT_DECR_ATT_1]',ACTT_DECR_ATT_2 = '$data[ACTT_DECR_ATT_2]',ACTT_DECR_ATT_3 = '$data[ACTT_DECR_ATT_3]',ACTT_DECR_ATT_4 = '$data[ACTT_DECR_ATT_4]',ACTT_DECR_ATT_5 = '$data[ACTT_DECR_ATT_5]',ACTT_DECR_ATT_6 = '$data[ACTT_DECR_ATT_6]'
                                    ,ACTT_DATE = '$data[ACTT_DATE]',ACTT_WEBF = $data[ACTT_WEBF],ACTT_FLAG = $data[ACTT_FLAG],ACTT_USER_CREATE = $data[ACTT_USER_CREATE]
                                    ,ACTT_RECR = $data[ACTT_RECR],ACTT_PERSON = '$data[ACTT_PERSON]',ACTT_TEL = '$data[ACTT_TEL]'
                              WHERE ACTT_CODE = $data[ACTT_CODE]"; 
          
       }
       
       $this->_db->setQuery($qr);       
       if($this->_db->query()){
           return true;
       }else{
           return false;
       }
         
    }
    
    /**
     * Remove Actt item
    **/
    public function remove($cid){
        $cid = implode(',', $cid);
        
        $query = "DELETE FROM actt WHERE ACTT_CODE IN($cid)";
        
        $this->_db->setQuery($query);
        $this->_db->query();
    }
    
    /**
     * GET LIST FILE_NAME FROM ACTT_CODE 
    **/
    public function getFileNameFromACTT_CODE($cid){
        $qr = "SELECT ACTT_IMAGE_1,ACTT_IMAGE_2,ACTT_IMAGE_3,ACTT_IMAGE_4,ACTT_IMAGE_5,ACTT_ATTACHMENT_1,ACTT_ATTACHMENT_2,ACTT_ATTACHMENT_3,ACTT_ATTACHMENT_4,ACTT_ATTACHMENT_5,ACTT_ATTACHMENT_6
                 FROM actt WHERE ACTT_CODE = $cid";
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObject();
       
       return $result;
    }
    
    /**
     * GET ACTT From ACTT_CODE 
    **/
    function getActtFromID($actt_code){
        $qr = "SELECT ACTT_CODE,ACTT_NAME,ACTT_RECOMMENDED_DEGREE,ACTT_OCBA_CODE,ACTT_PERIOD_START,ACTT_PERIOD_FINISH,ACTT_VENUE
                            ,ACTT_TOCHUC,ACTT_TAITRO,ACTT_COOPERATION,ACTT_CONTACT,ACTT_EFFECT,ACTT_TARGET,ACTT_SEX,ACTT_NUMBER_OF_PARTICIPANTS
                            ,ACTT_ENTRY_FEE,ACTT_TOTAL_PROJECT_COST,ACTT_BUSINESS,ACTT_REMARKS,ACTT_MFAC_CODE_LIST,ACTT_MOBJ_CODE_LIST
                            ,ACTT_MCON_CODE_LIST,ACTT_IMAGE_1,ACTT_IMAGE_2,ACTT_IMAGE_3,ACTT_IMAGE_4,ACTT_IMAGE_5
                            ,ACTT_DECR_IMG_1,ACTT_DECR_IMG_2,ACTT_DECR_IMG_3,ACTT_DECR_IMG_4,ACTT_DECR_IMG_5
                            ,ACTT_ATTACHMENT_1,ACTT_ATTACHMENT_2,ACTT_ATTACHMENT_3,ACTT_ATTACHMENT_4,ACTT_ATTACHMENT_5,ACTT_ATTACHMENT_6
                            ,ACTT_DECR_ATT_1,ACTT_DECR_ATT_2,ACTT_DECR_ATT_3,ACTT_DECR_ATT_4,ACTT_DECR_ATT_5,ACTT_DECR_ATT_6
                            ,ACTT_DATE,ACTT_WEBF,ACTT_FLAG,ACTT_RECR,ACTT_PERSON,ACTT_TEL,ACTT_DBSY
                FROM actt WHERE ACTT_CODE = $actt_code";

        $this->_db->setQuery($qr);
        $result = $this->_db->loadObject();        
        return $result;
    }
    
    /**
     * Check OCBA_CODE exist
    **/
    public function checkExistOCBA_CODE($cid){
        $qr = "SELECT OCBA_CODE FROM ocba WHERE OCBA_FLAG = 1 AND OCBA_CODE = '$cid'";
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObject();
       
        if(!empty($result)){
            return true;
        }
        return false;
    }
    /**
     * Check ACTT_NAME exist
    **/
    public function checkExistACTT_NAME($ACTT_NAME){
        $qr = "SELECT ACTT_NAME FROM actt WHERE ACTT_NAME = '$ACTT_NAME'";
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObject();
       
        if(!empty($result)){
            return true;
        }
        return false;
    }
    
    /**
     * GET list activity
    **/
	function getAllActivity($list = null){

       $qr = "SELECT DISTINCT ACTT_OCBA_CODE,ACTT_CODE,ACTT_NAME,ACTT_EFFECT,OCBA_NAME,PREF_NAME,ACTT_MFAC_CODE_LIST,ACTT_MOBJ_CODE_LIST,ACTT_MCON_CODE_LIST,ACTT_NUMBER_OF_PARTICIPANTS,ACTT_PERIOD_START,ACTT_PERIOD_FINISH,ACTT_FLAG,ACTT_WEBF,ACTT_DBSY,ACTT_RECOMMENDED_DEGREE,ACTT_DATE
                    FROM actt
                    	LEFT JOIN ocba ON ACTT_OCBA_CODE = OCBA_CODE
                    	LEFT JOIN town ON OCBA_TOWN_CODE = TOWN_CODE
                    	LEFT JOIN pref ON TOWN_PREF_CODE = PREF_CODE";
            $where = array();
         //check user group
           $aut=new bgAuthorize();
          // check  user login
           $group=$aut->getUserGroup();
           $u=JFactory::getUser();
           $u_ocba= $u->USEM_OCBA_CODE;
           if($group==11)
           {
              $where[] = "ACTT_OCBA_CODE = '$u_ocba'";                 
           }
            
        //search
        if($list['PREF_CODE_SEARCH'] != 0){
            
            $where[] = "PREF_CODE = $list[PREF_CODE_SEARCH]";    
        }
        if($list['PEDE_CODE_SEARCH'] != 0){
            
            $where[] = "ACTT_RECOMMENDED_DEGREE = $list[PEDE_CODE_SEARCH]";    
        }
        if(!empty($list['ACTT_NAME_SEARCH'])){
            
            $where[] = "ACTT_NAME LIKE  '%$list[ACTT_NAME_SEARCH]%'";    
        }
        if(!empty($list['ACTT_NUMBER_OF_PARTICIPANTS_1_SEARCH'])){
            
            $where[] = "ACTT_NUMBER_OF_PARTICIPANTS >= $list[ACTT_NUMBER_OF_PARTICIPANTS_1_SEARCH]";    
        }
        if(!empty($list['ACTT_NUMBER_OF_PARTICIPANTS_2_SEARCH'])){
            
            $where[] = "ACTT_NUMBER_OF_PARTICIPANTS <= $list[ACTT_NUMBER_OF_PARTICIPANTS_2_SEARCH]";    
        }
        
        if(!empty($list['FROMUDATE_SEARCH']) && !empty($list['TOUDATE_SEARCH'])){
            
            $where[] = " date(ACTT_DATE) BETWEEN '$list[FROMUDATE_SEARCH]' AND '$list[TOUDATE_SEARCH]' ";    
        }else{
            if(!empty($list['FROMUDATE_SEARCH'])){
            
                $where[] = "date(ACTT_DATE) >= '$list[FROMUDATE_SEARCH]'";    
            }
            if(!empty($list['TOUDATE_SEARCH'])){
                
                $where[] = "date(ACTT_DATE) <= '$list[TOUDATE_SEARCH]'";    
            }
        }
        
        if(!empty($list['FROMDATE_SEARCH']) && !empty($list['TODATE_SEARCH'])){
            $where[] = "((ACTT_PERIOD_START BETWEEN '$list[FROMDATE_SEARCH]' AND '$list[TODATE_SEARCH]')
                         AND (ACTT_PERIOD_FINISH BETWEEN '$list[FROMDATE_SEARCH]' AND '$list[TODATE_SEARCH]'))
                        ";
            
        }else{
            if(!empty($list['FROMDATE_SEARCH'])){
            
                $where[] = "ACTT_PERIOD_START >= '$list[FROMDATE_SEARCH]'";    
            }
            if(!empty($list['TODATE_SEARCH'])){
                
                $where[] = "ACTT_PERIOD_FINISH <= '$list[TODATE_SEARCH]'";    
            }
        }
        
        if(isset($list['user_id'])){
            $where[] = "ACTT_USER_CREATE = $list[user_id]";
        }
        
        // search LIST MFAC
        $whereMFAC="";
        for($i=1;$i<HelperBG::getIDAuto('mfac','MFAC_CODE');$i++) {
            if(isset($list['MFACC'.$i])){
                if($whereMFAC==""){
                    $whereMFAC = $i;
                }else{
                    $whereMFAC =$whereMFAC.",".$i;
                }
            }   
        }
       $MFAC_SQL=array();
       if(($whereMFAC)!=null){
            $ar=explode(',',$whereMFAC);
            foreach ($ar as $value)
                {
                    $MFAC_SQL[] = "ACTT_MFAC_CODE_LIST LIKE '%$value%'";
                }
            
        }
        if(!empty($MFAC_SQL)){
            $MFAC_SQL = implode(' OR ', $MFAC_SQL);
             $where[]="(".$MFAC_SQL.")";
        }
        
        // search LIST MOBJ
        $whereMOBJ="";
        for($i=1;$i<HelperBG::getIDAuto('mobj','MOBJ_CODE');$i++) {
            if(isset($list['MOBJJ'.$i])){
                if($whereMOBJ==""){
                    $whereMOBJ = $i;
                }else{
                    $whereMOBJ =$whereMOBJ.",".$i;
                }
            }   
        }
       $MOBJ_SQL=array();
       if(($whereMOBJ)!=null){
            $ar=explode(',',$whereMOBJ);
            foreach ($ar as $value)
                {
                    $MOBJ_SQL[] = "ACTT_MOBJ_CODE_LIST LIKE '%$value%'";
                }
            
        }
        if(!empty($MOBJ_SQL)){
            $MOBJ_SQL = implode(' OR ', $MOBJ_SQL);
             $where[]="(". $MOBJ_SQL.")";
        }
        
        // search LIST MCON
        $whereMCON="";
        for($i=1;$i<HelperBG::getIDAuto('mcon','MCON_CODE');$i++) {
            if(isset($list['MCONN'.$i])){
                if($whereMCON==""){
                    $whereMCON = $i;
                }else{
                    $whereMCON =$whereMCON.",".$i;
                }
            }   
        }
       $MCON_SQL=array();
       if(($whereMCON)!=null){
            $ar=explode(',',$whereMCON);
            foreach ($ar as $value)
                {
                    $MCON_SQL[] = "ACTT_MCON_CODE_LIST LIKE '%$value%'";
                }
            
        }
        if(!empty($MCON_SQL)){
            $MCON_SQL = implode(' OR ', $MCON_SQL);
             $where[]= "(" . $MCON_SQL . ")";
        }
        
        if($where){
            $where = ' WHERE '.implode(' AND ', $where);
        }else{
            $where = null;
        }
        // get total number record
        $this->_total = $this->getTotal($where);
         
        $qr .= $where;
       
        // order by
        $qr .= " ORDER BY ACTT_DATE DESC, ACTT_CODE DESC"; 
        // pagination
        $qr .= " LIMIT ".$this->getState('limitstart').",".$this->getState('limit');
        /*echo $qr;*/
        
        // load data
        $this->_db->setQuery($qr);
        $result = $this->_db->loadObjectList();
        $a = array();
        foreach($result as $value){
            $list_type = array();
            
            $mfac = $this->getListNameMFAC($value->ACTT_MFAC_CODE_LIST);
            $temp1 = array();
            if($mfac != null){             
                foreach($mfac as $item1){
                    $temp1[] = $item1->MFAC_NAME;
                }
            }
            if($temp1 != null){
                $temp1 = implode(",",$temp1); 
                $list_type[] = $temp1;   
            }
            $mobj = $this->getListNameMOBJ($value->ACTT_MOBJ_CODE_LIST);
            $temp2 = array();
            if($mobj != null){             
                foreach($mobj as $item2){
                    $temp2[] = $item2->MOBJ_NAME;
                }
            }
            if($temp2 != null){
                $temp2 = implode(",",$temp2);
                $list_type[] = $temp2; 
            }
            
            $mcon = $this->getListNameMCON($value->ACTT_MCON_CODE_LIST);
            $temp3 = array();
            if($mcon != null){             
                foreach($mcon as $item3){
                    $temp3[] = $item3->MCON_NAME;
                }
            }
            if($temp3 != null){
                $temp3 = implode(",",$temp3);
                $list_type[] = $temp3;
            }
            
            if($list_type != null){
                $value->LIST_TYPE = implode(",",$list_type);    
            }
            
        }
        
        return $result;
	}
    /**
     * GET list center - club (ocba)
    **/
    function getListOcba($where = null){

	   $qr = "SELECT OCBA_CODE,OCBA_NAME FROM ocba WHERE OCBA_FLAG = 1";
       // filter
       if($where){
            $qr .= " AND OCBA_NAME LIKE '%$where%' OR OCBA_CODE = '$where' ";
       }
       // order by
       $qr .= " ORDER BY OCBA_CODE ASC";
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list name Facility (mfac)
    **/
    function getListNameMFAC($where){

	   $qr = "SELECT MFAC_NAME FROM mfac WHERE MFAC_CODE IN ($where)";
       // order by
       $qr .= " ORDER BY MFAC_CODE ASC"; 
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list name Target (MOBJ)
    **/
    function getListNameMOBJ($where){

	   $qr = "SELECT MOBJ_NAME FROM mobj WHERE MOBJ_CODE IN ($where)";
       // order by
       $qr .= " ORDER BY MOBJ_CODE ASC"; 
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list Name Content (MCON)
    **/
    function getListNameMCON($where){

	   $qr = "SELECT MCON_NAME FROM mcon WHERE MCON_CODE IN ($where)";
       // order by
       $qr .= " ORDER BY MCON_CODE ASC"; 
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET total
    **/
    function getTotal($where = null){
        // Load the content if it doesn't already exist
        if ($this->_total === null) {
            
            $query = "SELECT count(DISTINCT ACTT_CODE)
                        FROM actt
                    	LEFT JOIN ocba ON ACTT_OCBA_CODE = OCBA_CODE
                    	LEFT JOIN town ON OCBA_TOWN_CODE = TOWN_CODE
                    	LEFT JOIN pref ON TOWN_PREF_CODE = PREF_CODE $where";
            
            $this->_db->setQuery($query);
            $this->_total = $this->_db->loadResult();
        }
        
        return $this->_total;
    } 
    /**
     * GET pagination
    **/
    function getPagination(){
        // Load the content if it doesn't already exist
        if (empty($this->_pagination)) {
            jimport('joomla.html.pagination');
            $this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
        }
        return $this->_pagination;
    }
    /**
     * GET list pref
    **/
    function getListPREF(){

	   $qr = "SELECT PREF_CODE,PREF_NAME FROM pref";
       
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list pede
    **/
    function getListPEDE(){

	   $qr = "SELECT PEDE_CODE,PEDE_NAME FROM pede ORDER BY PEDE_CODE ASC";
       
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list mfac
    **/
    function getListMFAC(){

	   $qr = "SELECT MFAC_CODE,MFAC_NAME FROM mfac ORDER BY MFAC_CODE ASC";
       
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list mobj
    **/
    function getListMOBJ(){

	   $qr = "SELECT MOBJ_CODE,MOBJ_NAME FROM mobj ORDER BY MOBJ_CODE ASC";
       
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
    /**
     * GET list mcon
    **/
    function getListMCON(){

	   $qr = "SELECT MCON_CODE,MCON_NAME FROM mcon ORDER BY MCON_CODE ASC";
       
       // load data
       $this->_db->setQuery($qr);
       $result = $this->_db->loadObjectList();
       
       return $result;
	}
}
